<template>
  <span v-if="time>0">{{time}}s</span>
</template>

<script>
export default {
  name: 'countDown',
  data() {
    return {
      time: 0,
      t1: 0
    };
  },
  props: {},
  methods: {
    countDownF(val) {
      return new Promise((resolve, reject) => {
        if (this.time > 0) {
          return;
        }
        this.time = val;
        if (val == 0) {
          clearInterval(f);
          return;
        }
        clearInterval(f);
        let f = setInterval(() => {
          val--;
          if (val == 0) {
            clearInterval(f);
            resolve();
          }
          this.time = val;
        }, 1000);
      });
    }
  }
};
</script>